<template>
  <div class="meituan">
      <p class="input"><input type="text" placeholder="账户名/手机号/Email" v-model='account'></p>
      <p class="input"><input type="text" placeholder="请输入您的密码" v-model="password"></p>
      <p><button @click="loginSuccess">登录</button></p>
      <p class="help">
          <span @click="goRegister">立即注册</span>
          <span>找回密码</span>
      </p>
      <p class="kefu">© 猫眼电影 客服电话：
          <span class="phone1">400-670-5335</span>
      </p>
  </div>
</template>

<script>
export default {
    data(){
        return{
            account:'',
            password:''
        }   
    },
    methods:{
        goRegister(){
            this.$router.replace('register');
        },
        loginSuccess(){
           if(JSON.parse(localStorage.getItem('register'))){
                var registerArr = JSON.parse(localStorage.getItem('register'));   
                if(this.account==registerArr.account&&this.password==registerArr.password){
                    alert('登录成功！');
                    this.$router.replace('loginSuccess');
                }else{
                    alert('您输入的账号或密码有误');
                    return;
                }
            }else{
                alert('此账户尚未注册，请先注册，再进行登录')
                return;
            }
        }
    }
}
</script>

<style scoped lang="scss">
.input{
    width:100%;
    height:50px;
    box-sizing: border-box;
    padding:10px;   
    border-bottom:1px solid #ddd;
    // font-size:14px;
    input{
        border:none;
        width:100%;
        height:100%;
        font-size:14px;
        &:focus{
            background-color: #ddd;
            outline:none;
            border-radius: 3px;
        }
    }
    
}
button{
    width:calc(100% - 20px);
    height:40px;
    box-sizing: border-box;
    margin:10px;
    text-align:center;
    color:#fff;
    background-color: #df2d2d;
    border:none;
    border-radius:10px;
    font-size:14px;
}
.help{
    width:100%;
    height:40px;
    box-sizing: border-box;
    padding:10px;
    display:flex;
    justify-content: space-between;
    align-items: center;
    font-size:14px;
    color:#fe8c00;
}
.kefu{
    width:100%;
    height:40px;
    display:flex;
    justify-content: center;
    align-items: center;
    font-size:14px;
    color:#333;
    .phone1{
        color:#df2d2d;
    }
}
</style>